<template>
  <div class="login-panel">
    <h1 class="title">后台管理系统</h1>
    <el-tabs type="border-card" class="demo-tabs" stretch v-model="currentTab">
      <el-tab-pane name="account">
        <template #label>
          <span class="custom-tabs-label">
            <i class="el-icon-user-solid"></i>
            <span>账号登录</span>
          </span>
        </template>
        <LoginAccount ref="accountRef" />
      </el-tab-pane>
      <el-tab-pane name="phone">
        <template #label>
          <span class="custom-tabs-label">
            <i class="el-icon-mobile-phone"></i>
            <span>手机登录</span>
          </span>
        </template>
        <LoginPhone ref="phoneRef" />
      </el-tab-pane>
    </el-tabs>
    <div class="panel-fo">
      <el-checkbox v-model="isKeeppassword" label="记住密码" size="large" />
      <el-link type="primary">忘记密码</el-link>
    </div>
    <el-button type="primary" class="panel-btn" @click="Loginclick"
      >立即登录</el-button
    >
  </div>
</template>

<script>
import { defineComponent, ref } from 'vue'
import LoginAccount from './login-account.vue'
import LoginPhone from './login-phone.vue'
export default defineComponent({
  components: {
    LoginAccount,
    LoginPhone
  },
  setup() {
    //记住密码
    const isKeeppassword = ref(true)
    //获取account组件的dom
    const accountRef = ref()
    const phoneRef = ref()
    //区分切换的tab
    const currentTab = ref('account')
    //登录时触发的事件
    const Loginclick = () => {
      if (currentTab.value === 'account') {
        accountRef.value?.loginaction(isKeeppassword)
      } else {
        phoneRef.value?.LoginPhone()
      }
    }
    return {
      isKeeppassword,
      Loginclick,
      accountRef,
      phoneRef,
      currentTab
    }
  }
})
</script>

<style lang="less" scoped>
.login-panel {
  width: 320px;
  margin-bottom: 120px;
  .title {
    text-align: center;
  }
  .panel-fo {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
  }
  .el-link {
    margin-bottom: 5px;
  }
  .panel-btn {
    margin-top: 10px;
    width: 100%;
  }
}
</style>
